package com.qf.md.type.controller;

import com.qf.common.R;
import com.qf.entity.md.type.MdItemType;
import com.qf.md.type.param.TypeParam;
import com.qf.md.type.service.MdItemTypeService;
import com.qf.md.type.vo.MdItemTypeVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ==== 天道酬勤 ====
 *
 * @author douzhouzhou
 * @date 2025/3/1
 * <p>
 * ==== 行稳致远 进而有为 ====
 */
//xixixi
@RestController
@RequestMapping("/md/type")
@Api(tags = "商品类型管理")
@Slf4j// 日志 private final Logger log = LoggerFactory.getLogger(MdItemTypeController.class);
public class MdItemTypeController {

    @Resource
    private MdItemTypeService mdItemTypeService;
    @GetMapping("/list")
    public R<List<MdItemTypeVO>> findTypeVO() {
        return R.ok(mdItemTypeService.findTypeVO());
    }
    @PostMapping("/deleteById")
    public R<String> deleteType(long id) {
        System.out.println("id = " + id);
        mdItemTypeService.deleteById(id);
        return R.ok("删除成功");
    }
    //根据id查询信息
    @GetMapping("/info")
    public R<MdItemType> info(long id) {
        System.out.println("id = " + id);
        return R.ok(mdItemTypeService.typeInfo(id));
    }
    @PostMapping("/save")
    public R<String> save(@RequestBody TypeParam typeParam) {
        System.out.println(typeParam);
        mdItemTypeService.save(typeParam);
        return R.ok("保存成功");
    }
}
